package com.baiwei.vpnapi.entity.reqentity;
import com.baiwei.vpnapi.exception.BusinessEnum;
import com.baiwei.vpnapi.exception.PaymentException;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.ModelAttribute;
import java.util.ArrayList;

/**
 * @program: vpnapi
 * @description: 套餐购买订单提交输入对象
 * @author: Mr. Stone
 * @create: 2020-03-06 18:42
 **/
@Data
public class PaymentInput implements Validatable{

    @Override
    public void validation() {
        if(packageId == null){
            throw new PaymentException(BusinessEnum.PAYMENT_PACKAGE_ID_EMPTY);
        }
        if(payMethod == null || payMethod.length() == 0) {
            throw new PaymentException(BusinessEnum.PAYMENT_METHOD_EMPTY);
        }
    }

    @ModelAttribute("payment")
    public PaymentInput getInput() {
        return new PaymentInput();
    }

    private String payMethod;
    private String packageId;

    public PaymentInput(String payMethod, String packageId) {
        this.payMethod = payMethod;
        this.packageId = packageId;
    }

    public PaymentInput() {
    }

    public String getPayMethod() {
        return payMethod;
    }

    public void setPayMethod(String payMethod) {
        this.payMethod = payMethod;
    }

    public String getPackageId() {
        return packageId;
    }

    public void setPackageId(String packageId) {
        this.packageId = packageId;
    }
}
